package pathfind;

import java.util.ArrayList;

public class PathFinder {
	private NodeMap map;
	private ArrayList<Point> current = new ArrayList<Point>();
public PathFinder(NodeMap map)
{
	this.map = map;
}
public void step()
{
	ArrayList<Point> next    = new ArrayList<Point>();
	for(Point i:current)
	{
		ArrayList<Point> arr=map.spred(i.getx(),i.gety());
		if(arr.size() !=0){
		for(Point j:arr)
		{
			next.add(j);
		}}
	}
	current.clear();
	current.addAll(next);
}
public void start()
{
	map.clean();
	current.add(map.getstart());
}
public void start(int x,int y)
{
	map.clean();
	map.setStart(x, y);
	current.add(map.getstart());
}
public void run()
{
	while(current.size() !=0 )
	{
		step();
	}
}
}
